package com.smarttest.common.util.serializer;

import static com.alibaba.fastjson.serializer.SerializerFeature.WriteNullListAsEmpty;
import static com.alibaba.fastjson.serializer.SerializerFeature.WriteNullStringAsEmpty;

import com.alibaba.fastjson.JSON;

public class JsonSerializer {
	
	public static byte[] toJson(Object obj){
		return JSON.toJSONBytes(obj, WriteNullListAsEmpty, WriteNullStringAsEmpty);
    }
	
	public static String toString(Object obj) {
		return JSON.toJSONString(obj, WriteNullListAsEmpty, WriteNullStringAsEmpty );
	}
    
    public static <T> T toObject(String json,Class<T> clazz){
    	return JSON.parseObject(json, clazz);
    }
}
